package cn.edu.scau.cmi.yangminghao.client;

import cn.edu.scau.cmi.yangminghao.Adapter1.InformationAdapter;
import javafx.application.Application;
import javafx.geometry.Insets;
import javafx.scene.Scene;
import javafx.scene.control.Alert;
import javafx.scene.control.Alert.AlertType;
import javafx.scene.control.Button;
import javafx.scene.control.Label;
import javafx.scene.control.TextField;
import javafx.scene.layout.HBox;
import javafx.scene.layout.VBox;
import javafx.scene.text.Font;
import javafx.scene.text.FontPosture;
import javafx.scene.text.FontWeight;
import javafx.stage.Stage;

public class InterProgrammingClient1 extends Application{
	public void start(Stage primaryStage) {
		
		VBox Vbox1 = new VBox();
		
		VBox vbox1= new VBox();
		vbox1.setPadding(new Insets(10, 10, 0,120));
		Label label1 = new Label("注册用户");
		label1.setFont(Font.font("Timer New Roman",
		FontWeight.BOLD, FontPosture.ITALIC, 40));
		vbox1.getChildren().add(label1);
		
		HBox hbox2 = new HBox();
		TextField text1 = new TextField();
		hbox2.getChildren().addAll(new Label("Name:	 "),text1);
		hbox2.setPadding(new Insets(50,0,20,100));
		
		HBox hbox3 = new HBox();
		TextField text2 = new TextField();
		hbox3.getChildren().addAll(new Label("Age:	         "),text2);
		hbox3.setPadding(new Insets(10,0,20,100));
		
		HBox hbox4 = new HBox();
		TextField text3 = new TextField();
		hbox4.getChildren().addAll(new Label("Sex:	         "),text3);
		hbox4.setPadding(new Insets(10,0,20,100));
		
		HBox hbox5 = new HBox();
		TextField text4 = new TextField();
		hbox5.getChildren().addAll(new Label("Password: "),text4);
		hbox5.setPadding(new Insets(10,0,20,100));
		
		HBox hbox6 = new HBox();
		TextField text5 = new TextField();
		hbox6.getChildren().addAll(new Label("Password:\n(confirm):	 "),text5);
		hbox6.setPadding(new Insets(10,0,20,100));
		
		Button button1 = new Button("Create");
		HBox hbox7 = new HBox();
		hbox7.setPadding(new Insets(10,0,20,180));
		hbox7.getChildren().add(button1);
		
		button1.setOnAction(e->{
			InformationAdapter user1 = new InformationAdapter();
			if(user1.checkPassword(text4.getText(),text5.getText())) {
				Alert alert = new Alert(AlertType.INFORMATION);
				alert.setTitle("创建");
				alert.setHeaderText(null);	
				alert.setContentText("成功创建！");
				alert.showAndWait();	
				
			}
			else{
				Alert warning = new Alert(Alert.AlertType.WARNING,"创建失败,前后输入的密码不一致");
				Button warn = new Button();		
				warning.showAndWait();
			}
		});
		Vbox1.getChildren().addAll(vbox1,hbox2,hbox3,hbox4,hbox5,hbox6,hbox7);
		Scene scene = new Scene(Vbox1,400,500);
		primaryStage.setTitle("实验四：类适配器");
		primaryStage.setScene(scene);
		primaryStage.show();
		
		
		
	}
	public static void main(String[] args) {
		
		Application.launch(args);
	}
	

}
